//
//  ComposeTitleView.swift
//  WBDemo
//
//  Created by Jin on 2018/5/11.
//  Copyright © 2018年 com.baidu.123. All rights reserved.
//

import UIKit
import SnapKit

class ComposeTitleView: UIView {

    private lazy var content:UIView = {
        let content = UIView()
        content.frame = CGRect(x: 0, y: 0, width: 200, height: 44)
        return content
    }()
    
    private lazy var titleLabel:UILabel = {
        let lab = UILabel()
        lab.text = "发微博"
        lab.textAlignment = .center
        lab.textColor = UIColor.black
        lab.font = UIFont.boldSystemFont(ofSize: 16)
        lab.sizeToFit()
        return lab
    }()
    private lazy var screenNameLabel:UILabel = {
        let lab = UILabel()
        lab.text = UserAccount.loadUserAccount()?.screen_name
        lab.textAlignment = .center
        lab.textColor = UIColor.gray
        lab.font = UIFont.systemFont(ofSize: 12)
        lab.sizeToFit()
        return lab
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented!")
    }
}

extension ComposeTitleView {
    private func setupUI(){
        
        addSubview(content)
        content.addSubview(titleLabel)
        content.addSubview(screenNameLabel)
        
        content.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
        }
        titleLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.width.equalToSuperview()
            make.top.equalToSuperview().offset(5)
        }
        screenNameLabel.snp.makeConstraints { (make) in
            make.centerX.equalTo(titleLabel.snp.centerX)
            make.top.equalTo(titleLabel.snp.bottom).offset(3)
            make.width.equalTo(self.titleLabel.snp.width)
        }
    }
}
